﻿@model CommentCreateViewModel
<script type="text/javascript" src="@this.Static("~/Scripts/jquery.validate.min.js")"></script>
<script type="text/javascript" src="@this.Static("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
<article id="new-comment">
    @using (Html.BeginForm("Create", "Comment"))
    {
        <fieldset>
            <legend>New Comment</legend>
            @Html.ValidationSummary(true)
            @Html.HiddenFor(model => model.CommentPostId)
            @if (Request.IsAuthenticated)
            {
                @Html.HiddenFor(model => model.CommentName)
                @Html.HiddenFor(model => model.CommentEmail)
            }
            else
            {
                <div class="editor-label">
                    @Html.LabelFor(model => model.CommentName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.CommentName)
                    @Html.ValidationMessageFor(model => model.CommentName)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.CommentEmail)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.CommentEmail)
                    @Html.ValidationMessageFor(model => model.CommentEmail)
                </div>
            }
            <div class="editor-label">
                @Html.LabelFor(model => model.CommentText)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.CommentText)
                @Html.ValidationMessageFor(model => model.CommentText)
            </div>
            @if (!string.IsNullOrWhiteSpace(Config.ReCaptchaPublicKey) && !string.IsNullOrWhiteSpace(Config.ReCaptchaPrivateKey))
            {
                <div class="editor-label">
                    @Html.Label("ReCaptcha")
                </div>
                <div class="editor-field">
                    @ReCaptcha.GetHtml(publicKey: Config.ReCaptchaPublicKey, language: Request.GetClientCulture().TwoLetterISOLanguageName, theme: "clean")
                    @Html.ValidationMessage("ReCaptcha")
                </div>
            }
            <p>
                <input type="submit" value="Submit" />
            </p>
        </fieldset>
    }
</article>
